package com.itheima.web.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/*
 服务器输出字符数据到浏览器,处理响应乱码
 */
@WebServlet("/responseServlet03")
public class ResponseServlet03 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*//设置流的编码
        response.setCharacterEncoding("utf-8");
        //告诉浏览器，服务器发送的消息体数据的编码。建议浏览器使用该编码解码
        response.setHeader("content-type","text/html;charset=utf-8");*/

        //处理乱码，简单写法
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("你好啊");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
